﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using TyMES.Model.Record;
using TyMES.Model;

namespace TyMES.ViewModel.Record.MaterialBindRecordVMs
{
    public partial class MaterialBindRecordListVM : BasePagedListVM<MaterialBindRecord_View, MaterialBindRecordSearcher>
    {
        
        protected override IEnumerable<IGridColumn<MaterialBindRecord_View>> InitGridHeader()
        {
            return new List<GridColumn<MaterialBindRecord_View>>{
                
                this.MakeGridHeader(x => x.MaterialBindRecord_lineCode).SetTitle(@Localizer["Page.产线编码"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_stationCode).SetTitle(@Localizer["Page.工位编码"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_orderCode).SetTitle(@Localizer["Page.工单编号"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_scheduleCode).SetTitle(@Localizer["Page.排程编码"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_snNumber).SetTitle(@Localizer["Page.SN编码"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_assemblyMaterialCode).SetTitle(@Localizer["Page.组件物料编号"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_assemblyMaterialQty).SetTitle(@Localizer["Page.组件物料数量"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_assemblySort).SetTitle(@Localizer["Page.组装顺序"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_assemblyTime).SetTitle(@Localizer["Page.组装时间"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_assemblyMaterialName).SetTitle(@Localizer["Page.组件物料名称"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_assemblyMaterialVersion).SetTitle(@Localizer["Page.组件物料版本"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_assemblyMaterialSn).SetTitle(@Localizer["Page.组件物料sn"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_materialBatchNo).SetTitle(@Localizer["Page.组件物料批次"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_uploadflag).SetTitle(@Localizer["Page.上传标志位"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_CreateTime).SetTitle(@Localizer["_Admin.CreateTime"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_UpdateTime).SetTitle(@Localizer["_Admin.UpdateTime"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_CreateBy).SetTitle(@Localizer["_Admin.CreateBy"].Value),
                this.MakeGridHeader(x => x.MaterialBindRecord_UpdateBy).SetTitle(@Localizer["_Admin.UpdateBy"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<MaterialBindRecord_View> GetSearchQuery()
        {
            var query = DC.Set<MaterialBindRecord>()
                
                .CheckContain(Searcher.LineCode, x=>x.LineCode)
                .CheckContain(Searcher.StationCode, x=>x.StationCode)
                .CheckContain(Searcher.OrderCode, x=>x.OrderCode)
                .CheckContain(Searcher.ScheduleCode, x=>x.ScheduleCode)
                .CheckContain(Searcher.SnNumber, x=>x.SnNumber)
                .CheckContain(Searcher.AssemblyMaterialCode, x=>x.AssemblyMaterialCode)
                .CheckContain(Searcher.AssemblyMaterialQty, x=>x.AssemblyMaterialQty)
                .CheckContain(Searcher.AssemblySort, x=>x.AssemblySort)
                .CheckContain(Searcher.AssemblyTime, x=>x.AssemblyTime)
                .CheckContain(Searcher.AssemblyMaterialName, x=>x.AssemblyMaterialName)
                .CheckContain(Searcher.AssemblyMaterialVersion, x=>x.AssemblyMaterialVersion)
                .CheckContain(Searcher.AssemblyMaterialSn, x=>x.AssemblyMaterialSn)
                .CheckContain(Searcher.MaterialBatchNo, x=>x.MaterialBatchNo)
                .CheckEqual(Searcher.Uploadflag, x=>x.Uploadflag)
                .CheckBetween(Searcher.CreateTime?.GetStartTime(), Searcher.CreateTime?.GetEndTime(), x => x.CreateTime, includeMax: false)
                .CheckBetween(Searcher.UpdateTime?.GetStartTime(), Searcher.UpdateTime?.GetEndTime(), x => x.UpdateTime, includeMax: false)
                .CheckContain(Searcher.CreateBy, x=>x.CreateBy)
                .CheckContain(Searcher.UpdateBy, x=>x.UpdateBy)
                .Select(x => new MaterialBindRecord_View
                {
				    ID = x.ID,
                    
                    MaterialBindRecord_lineCode = x.LineCode,
                    MaterialBindRecord_stationCode = x.StationCode,
                    MaterialBindRecord_orderCode = x.OrderCode,
                    MaterialBindRecord_scheduleCode = x.ScheduleCode,
                    MaterialBindRecord_snNumber = x.SnNumber,
                    MaterialBindRecord_assemblyMaterialCode = x.AssemblyMaterialCode,
                    MaterialBindRecord_assemblyMaterialQty = x.AssemblyMaterialQty,
                    MaterialBindRecord_assemblySort = x.AssemblySort,
                    MaterialBindRecord_assemblyTime = x.AssemblyTime,
                    MaterialBindRecord_assemblyMaterialName = x.AssemblyMaterialName,
                    MaterialBindRecord_assemblyMaterialVersion = x.AssemblyMaterialVersion,
                    MaterialBindRecord_assemblyMaterialSn = x.AssemblyMaterialSn,
                    MaterialBindRecord_materialBatchNo = x.MaterialBatchNo,
                    MaterialBindRecord_uploadflag = x.Uploadflag,
                    MaterialBindRecord_CreateTime = x.CreateTime,
                    MaterialBindRecord_UpdateTime = x.UpdateTime,
                    MaterialBindRecord_CreateBy = x.CreateBy,
                    MaterialBindRecord_UpdateBy = x.UpdateBy,
                })
                .OrderByDescending(x => x.ID);
            return query;
        }

        
    }
    public class MaterialBindRecord_View: MaterialBindRecord
    {
        
        public string MaterialBindRecord_lineCode { get; set; }
        public string MaterialBindRecord_stationCode { get; set; }
        public string MaterialBindRecord_orderCode { get; set; }
        public string MaterialBindRecord_scheduleCode { get; set; }
        public string MaterialBindRecord_snNumber { get; set; }
        public string MaterialBindRecord_assemblyMaterialCode { get; set; }
        public string MaterialBindRecord_assemblyMaterialQty { get; set; }
        public string MaterialBindRecord_assemblySort { get; set; }
        public string MaterialBindRecord_assemblyTime { get; set; }
        public string MaterialBindRecord_assemblyMaterialName { get; set; }
        public string MaterialBindRecord_assemblyMaterialVersion { get; set; }
        public string MaterialBindRecord_assemblyMaterialSn { get; set; }
        public string MaterialBindRecord_materialBatchNo { get; set; }
        public bool? MaterialBindRecord_uploadflag { get; set; }
        public DateTime? MaterialBindRecord_CreateTime { get; set; }
        public DateTime? MaterialBindRecord_UpdateTime { get; set; }
        public string MaterialBindRecord_CreateBy { get; set; }
        public string MaterialBindRecord_UpdateBy { get; set; }

    }

}